package cn.segment.core.common;

import java.io.IOException;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.segment.core.dictionary.TreeBuild;

/**
 * 模块配置类，载入词典
 * 
 * @author Huang Yue
 * @version 创建时间：2010-6-9 上午10:15:23
 */
public class Configuration extends Properties
{
    private static final long serialVersionUID = 4406186215873587381L;
    private TreeBuild dict;
    private Log log = LogFactory.getLog(Configuration.class);
    private static Configuration conf;

    private Configuration() {
        try
        {
            load(this.getClass().getResourceAsStream("/conf.properties"));
            
            this.dict = TreeBuild.create(getProperty("dict.basic"), getProperty("dict.basic.encode"));
        } catch (IOException e)
        {
            e.printStackTrace();
            log.error(e.getMessage());
        }
    }
    
    public synchronized static Configuration create(){
        if(conf == null){
            conf = new Configuration();
        }
        return conf;
    }
    
    public synchronized TreeBuild getDict(){
        return dict;
    }
    
    
}
